#include "data_unit.cpp"

int i=0,j=0,t=0;
void axes()
{
     int x1,x2,y1,y2;
     char val[20];
     setcolor(15);
     x1=100;
     x2=950;
     y1=50;
     y2=450;
     
     moveto(x1,y1);
     lineto(x1,y2);
     moveto(x1,y2);
     lineto(x2,y2);
     
     x2=150;
     y1=50;     
     settextstyle(3, 0, 1);
     sprintf(val, "%i" , 0); 
     outtextxy(80,460,val);
     outtextxy(940,420,"x,mm");
     outtextxy(90,10,"T,K");
     for (i=0;i<17;i++)
     {
         setcolor(15);
         setlinestyle(0,0,1);
         moveto(x2,455);
         lineto(x2,445);         
         sprintf(val, "%i" , x2-100);      
         outtextxy(x2-15,460, val);
         setcolor(7);
         setlinestyle(1,0,1);
         moveto(x2,445);
         lineto(x2,50);         
         x2+=50;
     }
     for (j=0;j<8;j++)
     {
         setcolor(15);
         setlinestyle(0,0,1);
         moveto(95,y1);
         lineto(105,y1);
         sprintf(val, "%i" , 450-y1); 
         outtextxy(65,y1-10 , val);
         setcolor(7);
         setlinestyle(1,0,1);
         moveto(105,y1);
         lineto(950,y1);
         y1+=50;
     }     
     setlinestyle(0,0,1);
}

void graphical()
{
     data_unit();
     double T,T1,T2,dx,dt,L,D,phi,b1,b2;
     int N,J;
     char val[20]; 
     inf.open("output.txt");    
     inf>>T;
     inf>>dt;
     inf>>L;
     inf>>dx;
     inf>>D;
     inf>>T1;
     inf>>T2;
     inf>>phi;
     inf>>N;
     inf>>J;
     int y1,y2,y3,y4,x1,x2;
     
     initwindow(1000,500, "Temperature <x>");
     graphdefaults();     
     axes();
     for (j=0;j<N-1;j++)
     {
       
       setcolor(t+306);
       x1=100;
       inf>>b1;
       y1=450-int(b1);
       moveto(x1,y1);
       x2=100+int(dx);
       for (i=0;i<J-1;i++)
       {
         inf>>b2;
         y2=450-int(b2);    
         if ((j%25)==0) 
         {     
           lineto(x2,y2);
           moveto(x2,y2);        
         } 
         if ((j<30) && ((j%4)==0))
         {     
           lineto(x2,y2);
           moveto(x2,y2);        
         } 
         x2+=int(dx);         
       }   
       t+=1;
     } 
     setcolor(15);
     outtextxy(420,10,"PRESS ENTER to continue");
     getch();
     cleardevice();
     axes();      
     setcolor(14);
     x1=100;
     inf>>b1;
     y1=450-int(b1);
     moveto(x1,y1);
     x2=100+int(dx);  
     for (i=0;i<J-1;i++)
     {
       inf>>b2;
       y2=450-int(b2);
       {               
         lineto(x2,y2);
         moveto(x2,y2);       
       } 
       x2+=int(dx);         
       }     
     setcolor(15);
     outtextxy(420,10,"PRESS anything to close");           
     getch();  
     closegraph();
     inf1.clear();
     inf1.close();
}
